package hsintiao.com.xintiaoAPP.config;/*
package yft.com.Springbootdemo.config;

import org.apache.shiro.authc.*;
import org.apache.shiro.authz.AuthorizationInfo;
import org.apache.shiro.authz.SimpleAuthorizationInfo;
import org.apache.shiro.realm.AuthorizingRealm;
import org.apache.shiro.subject.PrincipalCollection;
import org.springframework.beans.factory.annotation.Autowired;
import yft.com.Springbootdemo.entity.User;
import yft.com.Springbootdemo.service.UserService;

import java.util.Objects;

*/
/**
 * @author WEI
 * @version 1.0
 * @date 2020/7/12 14:44
 *//*

public class CustomRealm extends AuthorizingRealm {

    @Autowired
    private UserService userService;

//授权
    @Override
    protected AuthorizationInfo doGetAuthorizationInfo( PrincipalCollection principalCollection ) {

       SimpleAuthorizationInfo info = new SimpleAuthorizationInfo();
//          添加权限
//        info.addRole("user:list");

//        Subject subject = SecurityUtils.getSubject();

//        //拿到当前登录的对象信息
//        SysUser sysUser = (SysUser) subject.getPrincipal();

        //拿到数据库的权限进行授权
//        info.addStringPermission("用户的权限");
        return info;
    }


//认证
    @Override
    protected AuthenticationInfo doGetAuthenticationInfo( AuthenticationToken authenticationToken ) throws AuthenticationException {
        UsernamePasswordToken token = (UsernamePasswordToken) authenticationToken;
        User sysUser = userService.findByUsername(token.getUsername());
//        账号认证
        if (Objects.isNull(sysUser)){
            return null;
        }
        */
/*if (sysUser.getIsState() == 1){
            throw new LockedAccountException("用户被禁用");
        }*//*

//        Md5Hash md5Hash = new Md5Hash(sysUser.getPassWord());
//        Md5Hash md5Hash1 = md5Hash.fromHexString(sysUser.getPassWord());
//        //密码认证 1、获取当前认证用户的信息 2、当前用户的密码信息 3、认证名

        return new SimpleAuthenticationInfo(sysUser,sysUser.getPassword(),"");
    }

}
*/
